package com.desire.homework;

import org.jsoup.Jsoup;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class _28_查询身份证号归属地 {
    public static void main(String[] args) throws Exception {
        String id = "410211199905300030";
        String u = "https://qq.ip138.com/idsearch/index.asp?userid=" + id + "&action=idcard";
        System.out.println(id);

        String t = Jsoup.connect(u).get().toString();
        Pattern p = Pattern.compile("[\\u4e00-\\u9fa5\\s]+?<br>");
        Pattern p2 = Pattern.compile("男|女");
        Matcher m2 = p2.matcher(t);
        m2.find();
        System.out.println(m2.group());
        Pattern p3 = Pattern.compile("\\d{4}年\\d{2}月\\d{2}日");
        Matcher m3 = p3.matcher(t);
        m3.find();
        System.out.println(m3.group());
        Matcher m = p.matcher(t);

        while (m.find()) {
            System.out.println(m.group().replace(" <br>", "").replace("", ""));
            System.out.println(m.group().replaceAll("[^\\u4e00-\\u9fa5]", ""));
        }

    }
}
